package com.xintai.hetong.controller;

import java.util.List;

import com.xintai.hetong.domain.ErpHetongFile;
import com.xintai.hetong.service.IErpHetongFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xintai.common.annotation.Log;
import com.xintai.common.core.controller.BaseController;
import com.xintai.common.core.domain.AjaxResult;
import com.xintai.common.enums.BusinessType;
import com.xintai.common.core.page.TableDataInfo;

/**
 * 合同上传文件Controller
 *
 * @author xintai
 * @date 2021-02-20
 */
@RestController
@RequestMapping("/system/file")
public class ErpHetongFileController extends BaseController
{
    @Autowired
    private IErpHetongFileService erpHetongFileService;

    /**
     * 查询合同上传文件列表
     */
    @PreAuthorize("@ss.hasPermi('system:file:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpHetongFile erpHetongFile)
    {
        startPage();
        List<ErpHetongFile> list = erpHetongFileService.selectErpHetongFileList(erpHetongFile);
        return getDataTable(list);
    }

    /**
     * 获取合同上传文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:file:query')")
    @GetMapping(value = "/{htId}")
    public AjaxResult getInfo(@PathVariable("htId") Long htId)
    {
        return AjaxResult.success(erpHetongFileService.selectErpHetongFileById(htId));
    }

    /**
     * 新增合同上传文件
     */
    @PreAuthorize("@ss.hasPermi('system:file:add')")
    @Log(title = "合同上传文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpHetongFile erpHetongFile)
    {
        return toAjax(erpHetongFileService.insertErpHetongFile(erpHetongFile));
    }

    /**
     * 删除合同上传文件
     */
    @PreAuthorize("@ss.hasPermi('system:file:remove')")
    @Log(title = "合同上传文件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{htIds}")
    public AjaxResult remove(@PathVariable Long[] htIds)
    {
        return toAjax(erpHetongFileService.deleteErpHetongFileByIds(htIds));
    }
}